using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL {

/// <summary>
/// The CountryCodeTableManager class is responsible for managing BO.CountryCodeTable objects in the system.
/// </summary>
[DataObjectAttribute()]
public class CountryCodeTableManager
  {

#region "Public Methods"

/// <summary>
/// Gets a list with all CountryCodeTable objects in the database.
/// </summary>
/// <returns>A list with all CountryCodeTable from the database when the database contains any, or null otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, true)]
public static CountryCodeTableList GetList(){
return CountryCodeTableDB.GetList();
}

/// <summary>
/// Gets a single CountryCodeTable from the database without its data.
/// </summary>
/// <param name="countryCode">The CountryCode of the CountryCodeTable in the database.</param>
/// <returns>A CountryCodeTable object when the CountryCode exists in the database, or <see langword="null"/> otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static CountryCodeTable GetItem(short countryCode){
return GetItem(countryCode, false);
}

/// <summary>
/// Gets a single CountryCodeTable from the database.
/// </summary>
/// <param name="countryCode">The CountryCode of the CountryCodeTable in the database.</param>
/// <param name="getCountryCodeTableRecords">Determines whether to load all associated CountryCodeTable records as well.</param>
/// <returns>
/// A CountryCodeTable object when the CountryCode exists in the database, or <see langword="null"/> otherwise.
/// </returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static CountryCodeTable GetItem(short countryCode, bool getCountryCodeTableRecords){
CountryCodeTable myCountryCodeTable = CountryCodeTableDB.GetItem(countryCode);
return myCountryCodeTable;
}

/// <summary>
/// Saves a CountryCodeTable in the database.
/// </summary>
/// <param name="myCountryCodeTable">The CountryCodeTable instance to save.</param>
/// <returns>The new CountryCode if the CountryCodeTable is new in the database or the existing CountryCode when an item was updated.</returns>
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static short Save(CountryCodeTable myCountryCodeTable){
using (TransactionScope myTransactionScope = new TransactionScope()){
short countryCodeTableCountryCode = CountryCodeTableDB.Save(myCountryCodeTable);

//  Assign the CountryCodeTable its new (or existing CountryCode).
myCountryCodeTable.CountryCode = countryCodeTableCountryCode;

myTransactionScope.Complete();

return countryCodeTableCountryCode;
}
}

/// <summary>
/// Deletes a CountryCodeTable from the database.
/// </summary>
/// <param name="myCountryCodeTable">The CountryCodeTable instance to delete.</param>
/// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public static bool Delete(CountryCodeTable myCountryCodeTable){
return CountryCodeTableDB.Delete(myCountryCodeTable.CountryCode);
}

#endregion

}

}
